		function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
    return currentdate;
} 
$(document).ready(function(){
	    $("#user_name1").blur(
		function(){
			
		  for(var k=1;k<=localStorage.length;k++)
		   {
			   if(localStorage.getItem(k)!=null)
			   {
				   var user=localStorage.getItem(k);
			   user=JSON.parse(user);
			   {if((user.username!=null)&&(user.username==document.getElementById("user_name1").value))
		     	{$("span").eq(0).html("this username exists");
		      $("span").eq(0).css({"font-size":"15px","color":"red"});
			  break;}
		    
		   
			   else $("span").eq(0).empty();}
			   }
			   
			   else continue;
		}}
		
		
		)
			$("#password1").blur(
		function(){
	     reg=/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/;
		if(($(this).val()=="")||(!reg.test($("#password1").val())))
		{$("span").eq(1).html("set your password including number characters ");
		$("span").eq(1).css({"font-size":"15px","color":"red"});}
		else 
		{$("span").eq(1).empty();}
		});
		$("#password2").blur(function(){
			if(($(this).val())!=($("#password1").val()))
			{$("span").eq(2).html("different from your first password");
		       $("span").eq(2).css({"font-size":"15px","color":"red"});}
			else
			{$("span").eq(2).empty();}
				});
				
		$("#user_email").blur(function(){
			if(($(this).val())!=($("#user_email").val()))
			{$("span").eq(3).html("please write valid email address");
		       $("span").eq(3).css({"font-size":"15px","color":"red"});}
			else
			{$("span").eq(3).empty();}
				});
		})
	
	$("#usersform").submit(
	function(){if(!window.localStorage){
            alert("localstorage don't support");
	return false;}
	else{
		
		 $("span").each(function(){
			 if($(this).html()!=" ")
				 return false;
			 
		 });
		 alert("success");
           
		var i=localStorage.length;
		var date=getNowFormatDate();
		var data={
			username:$("#user_name1").val(),
			password1:$("#password1").val(),
			email:$("#user_email").val(),
			registertime:date,
			logtime:null
			}
			data=JSON.stringify(data);
		localStorage.setItem(i+1,data);
	window.location.href='../sign_in/sign_in.html';
	window.event.returnValue = false;}})
	// var re = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/; 
	// function getNowFormatDate() {
//     var date = new Date();
//     var seperator1 = "-";
//     var seperator2 = ":";
//     var month = date.getMonth() + 1;
//     var strDate = date.getDate();
//     if (month >= 1 && month <= 9) {
//         month = "0" + month;
//     }
//     if (strDate >= 0 && strDate <= 9) {
//         strDate = "0" + strDate;
//     }
//     currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
//             + " " + date.getHours() + seperator2 + date.getMinutes()
//             + seperator2 + date.getSeconds();
//     return currentdate;
// } 

// function checkForm(form){
// if(form.password1.value!=form.password2.value){
// alert("different!write your password again");
 // //return false;
// }else 
// if(form.password1.value.length<8)
// {alert("your password is too short!");
// //return false;
// }else 
// if (re.test(document.getElementById("user_email").value))
// {return storage();
// //return false;
// }
// else alert("wrong formatting of E-mail");}
	
// function storage(){if(!window.localStorage){
            // alert("localstorage don't support");
            // return false;
        // }else var i=(parseInt(localStorage.length/5));
		// if(i==0)
		    // {
		   // localStorage.setItem(i+1,document.getElementById("user_name1").value);
		   // localStorage.setItem("password"+(i+1),document.getElementById("password1").value);
		   // localStorage.setItem("email"+(i+1),document.getElementById("user_email").value);
		   // var data1=getNowFormatDate();
		   // localStorage.setItem("registertime"+(i+1),data1);
		   // localStorage.setItem(document.getElementById("user_name1").value+"_log_time",null);
		   // window.location.href='../sign_in/sign_in.html';
		   // window.event.returnValue = false;
		   // }
		   
		  // else {
		  // for(var k=0;k<localStorage.length;k++)
		   // {if(localStorage.getItem(localStorage.key(k))!=document.getElementById("user_name1").value)
		     // continue;
		    
			// else {alert("username exists");return false;}}
		   // {
		   // localStorage.setItem(i+1,document.getElementById("user_name1").value);
		   // localStorage.setItem("password"+(i+1),document.getElementById("password1").value);
		   // localStorage.setItem("email"+(i+1),document.getElementById("user_email").value);
		    // var data1=getNowFormatDate();
		   // localStorage.setItem("registertime"+(i+1),data1);
		   // localStorage.setItem(document.getElementById("user_name1").value+"_log_time",null);
		   // window.location.href='../sign_in/sign_in.html';
		   // window.event.returnValue = false;
		   // }
		// }	}
		 //if(localStorage.hasOwnProperty("document.getElementById("user_name1").value"))
		 //alert("user_name1 is used");